home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1998 March / Software of the Month Club 1998 March.iso / mac / Business / PowerReplace 6.3 / Plugin / PowerReplace User’s Guide / PowerReplace User’s Guide.rsrc / TEXT_135_7 - Technical Note.txt < prev    next >
Text File  |  1997-12-21  |  6KB  |  180 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. Types of filter files
  7. Definition. PowerReplace recognizes automatically two types of filter file: if a fitler can be represented by a conversion table ( or a dictionnary) like:
  8.     "\d000"     "seconf-stuff of 000" 
  9.     "\d001"     "seconf-stuff of 001"
  10.     .................................
  11.     "\d255"     "seconf-stuff of 255"
  12. this filter is called of type I. All other filters are called of type II.
  13.  
  14. In particulary, the first-stuff of each line in the type I filter represents only one character.
  15.  
  16. Example 1. A filter of type I:
  17.     "├í"     "á"  % first-stuff = "├í", one characters ! 
  18.     "\d65"  "a"         % first-stuff = "A", one characters !
  19.     "B"     "b"         % first-stuff = "B", one characters !
  20.     "\n"    "LF"        % first-stuff = LF,  one characters !
  21.  
  22. Example 2. A filter of type II:
  23.     "├í"     "á"   
  24.     "AB"    "C"         % first-stuff = ΓÇ£ABΓÇ¥, two characters !
  25.     "\n"    ""
  26.  
  27. Example 3. A filter of type II:
  28.     "A"     "B" 
  29.     "A"     "C"   
  30. PowerReplace can not construct a conversion table because "A" is defined twice.
  31.  
  32. Example 4. A filter of type II:
  33.     "A"     "B"   
  34.     "B"     "C"        
  35. If we construct a conversion table, it will be not equivalent to the filter. For example, this filter changes the text "ABC" to  "CCC". But if we construct a conversion table, we obtaine an other output text "BCC".
  36.  
  37. Set filter type. To set the type of a filter, put the following define line at the beginning of the filter:
  38.     #type 1
  39. or
  40.     #type 2
  41. See the filter "ShowASCII" in the Filter folder for an example.
  42.  
  43.  
  44. Profit. 
  45. - If your mac has enough memory (RAM) and your filter file has only a few lines, PowerReplace runs faster for type II filter than for type I.
  46. - else, PowerReplace works better for type I filter: it needs only a little memory, and runs very fast.
  47.  
  48. Speed Comparison
  49. Configuration:
  50. - Macintosh: test on PowerMac 6100/60 with system 7.5.5.
  51. - Input text file: repeat the string "abcdef├íSD├á12├óFD├⌐ji├¿=+├¬--├║RFD├╣<<├╗ED├╝lmlk <CR>" 
  52.                                 until file size >= 1500 KB.
  53.   
  54.    Application   Operation           Time
  55.  ┬á
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76. Optimizing Filter for Speed: An Example.
  77. We need change a 8 bits text to html format. We can write a filter file as (Filter E, 59 lines):
  78. % first, change accented letters to html format.
  79.     "├í"             "á"
  80.     "├á"             "à"
  81.     ..........................
  82.     "├╗"             "û"
  83.     "├╝"             "ü"
  84. % then change double-CR to paragraphe <P>,
  85. % change simple-CR to <BR>
  86.     "\r\r"          "<P>"
  87.     "\r"            "<BR>"
  88.  
  89. Filter E is of type II. If your input text is very big, it is possible that the conversion is not fast enough. In this case, you can cut the filter E into two filters as following to optimize for speed:
  90. Filter F (type I, 57 lines):
  91. % first, change accented letters to html format.
  92.     "├í"             "á"
  93.     "├á"             "à"
  94.     ..........................
  95.     "├╗"             "û"
  96.     "├╝"             "ü"
  97. And Filter G (type II, two lines):
  98. % then change double-CR to paragraphe <P>,
  99. % change simple-CR to <BR>
  100.     "\r\r"          "<P>"
  101.     "\r"            "<BR>"
  102.  
  103. Speed comparison (with the same configuration and input text as above)
  104.   
  105.                 Application  Operation    Time
  106.  
  107.  
  108.  
  109.  
  110.  
  111. Asterisk-sign(*) in the First-String: An Example.
  112. If the filter is:
  113. "A*B"         "ΓǪ"
  114. and the input text is "XYAABBBAAAABBAABBCD", 
  115. then the output text will be "XYΓǪBBΓǪBΓǪBCD".
  116.  
  117.  
  118. Writing and Debugging Complicate Filter
  119. PowerReplace can do more complicate text conversion. In the example in the ΓÇ£Tutorial Examples:Chapter 7:Write and Debug FilterΓÇ¥, we need select some information from the input file IllustratorText. 
  120.  
  121. This input file is not a ΓÇ£goodΓÇ¥ text file. It has a good view in Illustrator, but not in text editor. We want to extract only the lines beginning with %AI3_Note:, and some text after these lines. The following text is what we want extract from IllustratorText.
  122. %AI3_Note:
  123. (Black & White)
  124. %AI3_Note:Ptext 13_Jahrom_47848
  125. (Jahrom) Tx 
  126. %AI3_Note:Ptext 7_Al Kuwayt_29783
  127. (Al Kuwayt) Tx 
  128. %AI3_Note:Ptext 1_Kuwait_67972
  129. (Kuwait) Tx 
  130. %AI3_Note:Ptext 14_Taft_47045
  131. (Taft) Tx 
  132. %AI3_Note:Ptext 1_Iraq_24837
  133. (Iraq) Tx 
  134. Please see the complete input/output/filter files in the ΓÇ£Tutorial Examples:Chapter 7:Write and Debug FilterΓÇ¥ folder.
  135.  
  136. Γùè If you write a complicate filter, it is recommended that you use the ΓÇ£Convert In->OutΓÇ¥ mode to debug your filter. This mode saves your times. See the section Debugging Filter in the Chapter 4: Tutorial.
  137.  
  138. Γùè You can change the text style or text color in the Input and Output windows. Using ResEdit, change the resource 'Txtr', ID=141 for Input and ID=142 Output. 
  139.  
  140. Length of Line and String
  141. The length of each line must be less than 4096 characters. If the first-stuff is a single character in a line, then the second-stuff in this line must have less than 32 characters. The length of the string in the progress window must be less than 200 characters.
  142.  
  143. Limitations:
  144.  
  145. ΓÇó NULL character in input file
  146.  
  147. If your input file contains NULL characters (ascii = 0), PowerReplace may not work correctly. To solve this problem, you can save all NULL characters at the begin, and restore them at the end of your filter file. Your filter looks like:
  148.  
  149.    "\d000"      "[NULL]"  % make sur no [NULL] in input file
  150.    ......
  151.    ......
  152.    ......
  153.    "[NULL]"     "\d000"
  154.  
  155.  
  156. ΓÇó Big Insertion
  157.  
  158. If you use insertion tag "\>" in the second-string, then the first-string-found (the "source") must have less than 4096 characters.
  159.  
  160. Bad example: Your input text is of length 10KB, and looks like
  161.  
  162.    Begin of file
  163.    Chapter 1: Introduction
  164.    ......
  165.    ......
  166.    ......
  167.    Chapter 9 : Conclusion
  168.    Ene of file
  169.  
  170. The following filter may cause error:
  171.    "Chapter * :"      "toto" 
  172. because between "Chapter 1" and ":", there is no space. If there is no " :" in the middle of your input text, then the first-string-found is:
  173.  
  174.    Chapter 1: Introduction
  175.    ......
  176.    ......
  177.    ......
  178.    Chapter 2 :
  179.  
  180.